package com.example.othree.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 
 * </p>
 *
 * @author liaotao
 * @since 2024-09-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="TowerOzoneGradientObservations对象", description="")
public class TowerOzoneGradientObservations implements Serializable {

    private static final long serialVersionUID = 1L;

      @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private Double longitude;

    private Double latitude;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai")
    @TableField(value = "time")
    private Date time;

    @TableField("StationCode")
    private String StationCode;

    @TableField("PointName")
    private String PointName;

    @TableField("CO")
    private Double co;

    @TableField("NO2")
    private Double no2;

    @TableField("O3")
    private Double o3;

    @TableField("SO2")
    private Double so2;

    // 解析 PointName，提取名称和高度
    public String getLocation() {
        if (PointName == null || PointName.length() < 4) {
            return ""; // 防止字符串过短导致异常
        }
        return PointName.substring(2, 4); // 提取第3、4个字符（索引从0开始）
    }

    public Integer getHeight() {
        String heightStr = PointName.replaceAll("\\D+", ""); // 去掉非数字部分
        return heightStr.isEmpty() ? null : Integer.parseInt(heightStr);
    }

}
